#pragma once
#ifndef _D3D_POINTSPRITE_
#define _D3D_POINTSPRITE_

#include <windows.h>
#include <d3dx9.h>
#include "..\common\def.h"
#include "..\common\arraylist.hpp"
#include "..\common\common.h"
#include "d3d_util.h"

class CD3D9Device; 
struct D3DTexture2D; 

struct EE_EXPORT D3DPointSpriteGroup : public D3DRenderable
{
protected:
	friend struct D3DParticleShader; 
	friend struct D3DSprite; 
	int m_RenderFlags; 

public:
	string GetType() const; 
	ArrayList<D3DSprite*> m_RegisteredSprites; 
	ArrayList<Point> m_Sprites; 
	unsigned int m_Capacity;
	void Flush(); 

	D3DPointSpriteGroup(CD3D9Device* pDevice, const string szName, D3DTexture2D* const pTexture); 
	HRESULT Release(); 
	HRESULT Reload(); 
	void allocateBuffers(unsigned int newCount); 
	HRESULT addPointsprite(D3DSprite **pInOut); 
	LPDIRECT3DVERTEXBUFFER9 GetVertexBuffer(); 
	void ReallocateVertexBuffer(unsigned int uiCount); 
	virtual ~D3DPointSpriteGroup(); 
	D3DPointSpriteGroup(CD3D9Device* const pDevice); 
	
	void setTexture(Texture* pTexture, const unsigned int unit);
	Texture* getTexture(const unsigned int idx);
	unsigned int getVertexCount() const;
	HRESULT PreRender();
	void Render(const unsigned int vbOffset);
	HRESULT PostRender();
	
	void* getVertices();

}; 


//TODO: 
struct EE_EXPORT D3DSprite : public IResource
{
	D3DSprite(CD3D9Device* const pDevice); 

	D3DPointSpriteGroup *m_pGroup; 
	int m_Index; 
	Point m_Point; 

	HRESULT Reload(); 
	void Draw(); 
	void setRadius(const float &radius); 
	void setPosition(const Vector3f &position); 
	void setColor(const Color3f &color); 
	void setRenderFlags(const int flags); 
	string GetType() const; 
	HRESULT Release(); 
}; 


#endif